<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<form action="VieWGroups.php" method="post">
<?php
require 'dbconnect.php';

$result = mysql_query("SELECT * FROM groups");
echo '<select name="gid">';
while($row = mysql_fetch_array($result)){
    echo "<option value=\"".$row['id']."\" >".$row['groupname']."</option>";
}
echo "</select>";
?>
<input name="submit" type="submit">
</form>
<?php 
if (isset($_POST['gid'])){
    $result1 = mysql_query("SELECT * FROM groupstudent WHERE group_id='".$_POST['gid']."'");
    while ($row1 = mysql_fetch_array($result1) ){
        $result2 = mysql_query("SELECT * FROM students WHERE id='".$row1['student_id']."'");
            $row2 = mysql_fetch_array($result2);
                echo "<table border='1'>
                <tr>
                    <th>Nimi</th>
                    <th>Isikukood</th>
                    <th>Aadress</th>
                    <th>Telefon</th>
                    <th>Email</th>
                </tr>";
       
        	    echo "<tr>";
        	    echo "<td>". $row2['nimi']. "</td>";
        	    echo "<td>". $row2['isikukood']. "</td>";
        	    echo "<td>". $row2['aadress']. "</td>";
        	    echo "<td>". $row2['telefon']. "</td>";
        	    echo "<td>". $row2['email']. "</td>";
        	    echo "</tr>";
            	
            	echo "</table>";
    }
}

?>


</body>
</html>



